package com.mjk.common.core.jdbc.service.parse.type.impl.sql.type;


import com.mjk.common.core.jdbc.service.parse.type.impl.sql.type.impl.BeeSqlChoosePrase;
import com.mjk.common.core.jdbc.service.parse.type.impl.sql.type.impl.BeeSqlForEachPrase;
import com.mjk.common.core.jdbc.service.parse.type.impl.sql.type.impl.BeeSqlIfPrase;

import java.util.Map;

/**
 * SQL解析的类型 if / foreach /choose
 * @author Administrator
 *
 */
public enum SqlPraseType {
	IF(new BeeSqlIfPrase()),
	FOREACH(new BeeSqlForEachPrase()),
	CHOOSE(new BeeSqlChoosePrase())
	;
	private final IBeeSqlPrase prase;
	SqlPraseType(IBeeSqlPrase clazz){
		this.prase = clazz;
	}
	/**
	 * 获取SQL语句
     */
	public static String getSql(String sql,Map<String,Object> params){
		for (SqlPraseType type : SqlPraseType.values()) {
			sql = type.prase.praseSql(sql, params);
		}
		return sql;
	}
}
